/*
 * @Description: 
 * @Author: mmzhang
 * @Date: 2022-04-15 11:10:23
 * @LastEditTime: 2022-07-28 14:54:13
 */

import table from '@/components/dt/table/render.js'
import nameOpt from '@/biz/option/name.js'
import dateOpt from '@/biz/option/date.js'
import Opt from '@/components/dt/info/Opt.js'
import ruleOpt from '@/biz/option/rule.js'
import dt from '@dt/dt'

let _this = null
class ParamsRemark {
  constructor(vm) {
    this.opts = {}
    _this = vm
    this.build()
  }
  build() {
    this.opts = {
      remarkOptions: [
      {
        key: 'remark',
        title: '备注内容',
        placeholder: '请输入备注',
        input: {
          type: 'textarea',
          autosize: {
            minRows: 5,
            maxRows: 8
          },
          showWordLimit: true,
          maxlength: 500,
        },
        rules: [
          ruleOpt.required('备注内容不能为空'),
          ruleOpt.max(500)
        ]
      }],
      columns: [
      {
        field: 'remark',
        title: '备注信息',
        minWidth: 300,
      },
      {
        field: 'createName',
        title: '备注人',
        minWidth: 100,
        cell: (info) => {
          return {
            value: (v) => {
              return info.createName + '(' + info.createWorkNo + ')'
            },
            text: {}
          }
        }
      },
      {
        field: 'createTime',
        minWidth: 150,
        title: '备注时间',
      },
      {
        title: '操作',
        width: 80,
        align: 'center',
        slots: {
          default: (params, h) => {
            let btns = []
            let btnFlag = false

            if (_this.orderStatusName == '认购') {
              btnFlag = _this.unlocking('0104010312')
            } else {
              btnFlag = _this.unlocking('0104030320')
            }

            btns.push({
              title: btnFlag && (dt.userInfo().userId ==
                  params.row.createId || dt.userInfo().currentRoleId == 10041) ?
                '删除' : '',
              event: 'onDelete',
              data: params.row
            })
            return table.cell.btns(_this, h, btns)
          }
        }
      }]
    }
  }
  options() {
    return this.opts
  }
}

export default ParamsRemark